<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = ['鹿晗', '王俊凯', '蔡徐坤', '彭于晏', '周杰伦', '刘德华', '吴彦祖'];
        var newArr = [];
        while (newArr.length < 4) {
            var num = Math.floor(Math.random() * 7);
            if (newArr.indexOf(arr[num]) === -1) {
                newArr.push(arr[num]);
            }
        }
        alert(newArr);
        console.log(newArr);
    </script>
</body>

</html>